package com.masterclient.app.businessmodule.homemodule.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.eoner.baselibrary.utils.GlideUtil;
import com.masterclient.app.R;
import com.masterclient.app.modules.income.model.HomeDataBean;
import java.util.List;

public class OtherMeetItemAdapter extends BaseQuickAdapter<HomeDataBean.HotEventItem , BaseViewHolder> {

    private OnClickStatusListener clickStatusListener;
    public OtherMeetItemAdapter() {
        super(R.layout.other_meet_item);
    }

    public interface OnClickStatusListener{
        void clickStatusBtn(String eventId,int position);
    }

    public void setOnClickStatusListener(OnClickStatusListener clickStatusListener){
        this.clickStatusListener = clickStatusListener;
    }

    @Override
    protected void convert(BaseViewHolder helper, HomeDataBean.HotEventItem item) {
        ImageView iv = helper.getView(R.id.iv_img);
        TextView tvName = helper.getView(R.id.tv_name);
        TextView tvCity = helper.getView(R.id.tv_city);
        TextView tvTime = helper.getView(R.id.tv_time);
        TextView tvStatus = helper.getView(R.id.tv_status);
        ImageView ivTag = helper.getView(R.id.iv_tag);
        TextView tvTag = helper.getView(R.id.tv_tag);

        if ("2".equals(item.status)){
            //进行中
            ivTag.setImageResource(R.mipmap.icon_meeting_tag);
            tvStatus.setVisibility(View.GONE);
        }else if("1".equals(item.status)){
            //进行中
            ivTag.setImageResource(R.mipmap.icon_meet_pre_tag);
            tvStatus.setVisibility(View.VISIBLE);
        }else{
            //已结束
            ivTag.setImageResource(R.mipmap.icon_meet_end_tag);
            tvStatus.setVisibility(View.GONE);
        }
        tvTag.setText(item.statusText);

        tvName.setText(item.name);
        tvCity.setText(item.city);
        tvTime.setText(item.eventTime);
        if ("0".equals(item.hasSubscribe)){
            tvStatus.setBackgroundResource(R.drawable.bg_meet_subscribe);
            tvStatus.setText("预约提醒");
            tvStatus.setOnClickListener(view -> {
                clickStatusListener.clickStatusBtn(item.event_id,helper.getAdapterPosition());
            });
        }else {
            tvStatus.setBackgroundResource(R.drawable.bg_meet_has_subscribe);
            tvStatus.setText("已预约");
        }
        GlideUtil.displayRoundImage(mContext, item.image, iv, 4, R.mipmap.defaults);
    }
}
